x86/spec-ctrl: Record the last write to MSR_SPEC_CTRL
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 28 Jan 2022 11:57:19 +0000 (11:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 4 Feb 2022 15:45:25 +0000 (15:45 +0000)
commit6ef732726add103ee8f63293e326ad43b1643239
tree5152f255a0533a34bdbec756a32d52805ef60f47
parent72ef02da23861f686c349a6808b2f4c9adc15f9f
x86/spec-ctrl: Record the last write to MSR_SPEC_CTRL

In some cases, writes to MSR_SPEC_CTRL do not have interesting side effects,
and we should implement lazy context switching like we do with other MSRs.

In the short term, this will be used by the SVM infrastructure, but I expect
to extend it to other contexts in due course.

Introduce cpu_info.last_spec_ctrl for the purpose, and cache writes made from
the boot/resume paths.  The value can't live in regular per-cpu data when it
is eventually used for PV guests when XPTI might be active.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(cherry picked from commit 00f2992b6c7a9d4090443c1a85bf83224a87eeb9)
xen/arch/x86/acpi/power.c
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/arch/x86/spec_ctrl.c
xen/include/asm-x86/current.h
xen/include/asm-x86/spec_ctrl_asm.h